Skip to content

feat(XCOD-82): background subagents as a documented setting, /tasks, lifecycle (part 2) - #28

Merged
pminev1 merged 1 commit into
devfrom
xcod-82-background
Sep 24, 2026
Merged

pminev1 merged 1 commit into
devfrom
xcod-82-background

Conversation

@pminev1

@pminev1 pminev1 commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

Part 2 of XCOD-82, completing the ticket. Part 1 (model selection) was #27.

Graduated

Monitoring

  • Server:
    • GET /experimental/background[?sessionID] lists task jobs with status, elapsed time, agent, resolved model and the rule that chose it.
    • POST /experimental/background/{jobID}/cancel cancels through the same run-state path as an abort, so the job's own descendants stop too.
  • TUI: /tasks (alias /background) shows the same list and refreshes every second. Enter opens a job's child session, and ctrl+d cancels it. ctrl+x is the leader key, which is why cancel isn't on it.

Lifecycle and parity

specs/background-subagents.md covers each lifecycle case, along with the test that covers it, and a parity table against Claude Code:

  • Abort: cancels the job and its subtasks, recursively.
  • Delete: cancels.
  • Compaction: doesn't touch jobs.
  • Process exit: jobs are lost, because the registry is process-local. The child session stays, so the task can resume via task_id.

Verification

Real terminal (pty, 140x45), with a real lunos TUI talking to an OpenAI-compatible model server:

  • The main agent launched General Task (background) — survey repo.
  • /tasks listed survey repo general · fake/m running · 21s.
  • ctrl+d showed the toast "Background subagent cancelled", and the row changed to cancelled.
  • Enter opened the child session, whose turn shows interrupted.

Tests:

  • task.test.ts is 24/24. New cases: the config key alone enables background runs, and a running job is listed with agent, model and rule, then cancelled.
  • The httpapi exercise covers both new routes: 210/210.
  • Full turbo typecheck passes after ./script/generate.ts.
  • Full suite: no new failures. One pty test, v2 pty HttpApi > serves location-wrapped PTY routes…, failed once under full-suite load. It passes 3/3 in isolation on this branch and 2/2 on dev, like the pty test already in the known-flaky list.

🤖 Generated with Claude Code

…lifecycle (part 2)

- Graduated: `"subagent": { "background": true }` (off by default) turns
  background subagents on; OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS still
  works as an alias. Every check (task tool, capabilities, session
  background route, run/local run) goes through backgroundEnabled(). Kept
  opt-in because upstream still ships it as experimental and its follow-up
  fixes (anomalyco#29179, anomalyco#30790, anomalyco#31162) were model-behaviour issues.
- Monitoring: GET /experimental/background[?sessionID] lists task jobs with
  status, elapsed, agent, resolved model and rule; POST
  /experimental/background/{jobID}/cancel cancels through the same run-state
  path as an abort. TUI /tasks (alias /background) shows the same, refreshes
  every second, opens a job's child session on Enter, cancels with ctrl+d.
- Lifecycle written down in specs/background-subagents.md, with the tests
  that cover each case: abort cancels recursively, delete cancels,
  compaction doesn't touch jobs, process exit loses them (registry is
  process-local) but the child session stays and resumes via task_id.
- Parity note against Claude Code in the same spec.

Verified in a real terminal (pty, 140x45) against an OpenAI-compatible
model server: the main agent launched "General Task (background) — survey
repo"; /tasks listed "survey repo  general · fake/m  running · 21s"; ctrl+d
→ "Background subagent cancelled", status "cancelled"; Enter opened the child
session, whose turn shows "interrupted".

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@pminev1
pminev1 merged commit e40f1c1 into dev Sep 24, 2026
4 of 6 checks passed
@pminev1
pminev1 deleted the xcod-82-background branch September 26, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant